<template>
<div>
    <el-form :model="form" label-width="auto" style="max-width: 600px;">
        <el-form-item label="姓名">
            <el-input v-model="form.name" />
        </el-form-item>
        <el-form-item label="年龄" prop="age">
            <el-input v-model.number="form.age" />
        </el-form-item>
        <el-form-item label="性别">
            <el-select v-model="form.sex" placeholder="请选择性别">
                <el-option label="男" value="男" />
                <el-option label="女" value="女" />
            </el-select>
        </el-form-item>
        <el-form-item label="语文">
            <el-input v-model.number="form.score.yw" type="number" />
        </el-form-item>
        <el-form-item label="数学">
            <el-input v-model.number="form.score.sx" type="number" />
        </el-form-item>
        <el-form-item label="英语">
            <el-input v-model.number="form.score.yy" type="number" />
        </el-form-item>
        <el-form-item>
            <el-button @click="form = null">重置</el-button>
            <el-button type="primary" @click="submit">提交</el-button>
        </el-form-item>
    </el-form>
</div>
</template>
<script>
import {ref} from 'vue';

export default {
    name: 'Report',
    emits:['addStu'],
    setup(props,cxt) {
        const sexList = [{ label: '男', value: '男', }, { label: '女', value: '女', },];
        const form = ref({ name: '', age: 0, sex: '', score: { yw: 0, sx: 0, yy: 0 }, avatar: '' });
        const submit=function(){
            cxt.emit('addStu',form.value)
            form.value = { name: '', age: 0, sex: '', score: { yw: 0, sx: 0, yy: 0 }, avatar: ''  };
        }
        
        return {
            sexList,
            form,
            submit

        }
    }
}

</script>
<style></style>